/**
 * @param {number[]} prices
 * @return {number}
 */
 var maxProfit = function(prices) {
  let profit = 0
  let miniPrice = prices[0]
  for(let i = 0;i < prices.length;i++){
      if(miniPrice > prices[i]) miniPrice = prices[i]
      profit = Math.max(profit,prices[i] - miniPrice)
  }
  return profit
};